Return to doc.sitecore.com

2.  Context Node
Prev Next

In Sitecore, the entire website – the entire information architecture including content, Extranet users and other data, every Item in that information architecture, every property of every Item and every language instance of every field in every Item – is exposed to the developer as a single XML document. 

For scalability concerns the actual storage may be implemented as numerous database records, but Sitecore will aggregate these records as needed such that they appear in memory as a single XML document.  Almost every operation in XSL deals with nodes in the XML document that is being processed, and the data to process is generally determined using XPath expressions. 

Much like URLs and file system paths, XPath expressions can be absolute (starting with “/”, the root of the XML document) or relative.  Relative XPath expressions are executed from what is called the context node, for instance by accessing the current node’s parent and grandparent with “..” and “../..”.  Nodes other than those related to the context node can be accessed through variables, or where only a single reference is used, directly through functions which retrieve those variables. 

Examples are the $sc_item and $sc_currentitem parameters, or anything returned by the sc:item XSL extension function.  The default boilerplate XSL rendering sets the context node to $sc_item, the Item the user is viewing unless overridden with a data source for the Rendering.


Prev Next